#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include "hexstring.h"
#include "../src/struct_util.h"
uint8_t buffer[2014] = {0};
int main(int argc, char const *argv[])
{
    int n = 0;
    const char cmp1[] = {0x01, 0x11, 0x12, 0x13, 0xa1};
    const char cmp2[] = {0x02, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0xB2, 0xB1};
    const char cmp3[] = {0x03, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0xa3};
    // int argint[10] = {0};
    uint8_t u8data[10] = {0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18};
    uint16_t u16data[10] = {0x2122, 0x2324, 0x2526, 0x2728, 0x292a};
    uint32_t u32data[10] = {0x31323334, 0x35363738, 0x393a3b3c};

    // u8
    n = struct_util_pack(buffer, "b3Bb", 0x01, u8data, 0x00A1);
    assert(0 == memcmp(buffer, cmp1, n));

    // u16
    n = struct_util_pack(buffer, "b4H<h", 0x02, u16data, 0xB1B2);
    assert(0 == memcmp(buffer, cmp2, n));

    // u32
    n = struct_util_pack(buffer, "b3Ib", 0x03, u32data, 0x00A3);
    assert(0 == memcmp(buffer, cmp3, n));
    n;
    return 0;
}
